API: gdk: Change get_drag_window() API
authorBenjamin Otte <otte@redhat.com>
Tue, 1 Feb 2011 17:11:35 +0000 (18:11 +0100)
committerBenjamin Otte <otte@redhat.com>
Tue, 1 Feb 2011 17:51:57 +0000 (18:51 +0100)
The previous function gdk_drag_get_protocol_for_display() took native
window handles, so it had to be changed. Because it didn't do what it
was named to do (it didn't return a protocol even though it was named
get_protocol) and because it doesn't operate on the display anymore but
on the actual window, it's now called gdk_window_get_drag_protocol().

12 files changed:
docs/reference/gdk/gdk3-sections.txt
gdk/gdk.symbols
gdk/gdkdisplay.c
gdk/gdkdisplayprivate.h
gdk/gdkdnd.h
gdk/gdkwindow.c
gdk/gdkwindow.h
gdk/gdkwindowimpl.h
gdk/x11/gdkdisplay-x11.c
gdk/x11/gdkprivate-x11.h
gdk/x11/gdkwindow-x11.c
gtk/gtksocket.c

index 846eeaa9861e542f51913768712319a394252d1e..574977d34e6546ae5af545ee19c66c054f3f441b 100644 (file)
@@ -882,11 +882,11 @@ gdk_drag_begin
 gdk_drag_begin_for_device
 gdk_drag_motion
 gdk_drop_finish
-gdk_drag_get_protocol_for_display
 GdkDragProtocol
 GdkDragAction
 gdk_drag_status
 gdk_drag_drop_succeeded
+gdk_window_get_drag_protocol
 
 gdk_drag_context_get_actions
 gdk_drag_context_get_suggested_action
index bf7210c792894940ad59fc8a575b4c10aa141dbf..b159b1ce329c6ff2a0916d311f73a6a9da4c0589 100644 (file)
@@ -143,7 +143,6 @@ gdk_drag_context_set_device
 gdk_drag_drop
 gdk_drag_drop_succeeded
 gdk_drag_find_window_for_screen
-gdk_drag_get_protocol_for_display
 gdk_drag_get_selection
 gdk_drag_motion
 gdk_drag_protocol_get_type G_GNUC_CONST
@@ -390,6 +389,7 @@ gdk_window_get_device_cursor
 gdk_window_get_device_events
 gdk_window_get_device_position
 gdk_window_get_display
+gdk_window_get_drag_protocol
 gdk_window_get_effective_parent
 gdk_window_get_effective_toplevel
 gdk_window_get_events
index 4caadef4ba0ad97ed39bebad8bf44b1b74626fc5..e4b518e21ad8a54f7d622f66351ed81795ebddc7 100644 (file)
@@ -1663,28 +1663,6 @@ gdk_display_get_app_launch_context (GdkDisplay *display)
   return GDK_DISPLAY_GET_CLASS(display)->get_app_launch_context (display);
 }
 
-/**
- * gdk_drag_get_protocol_for_display:
- * @display: the #GdkDisplay where the destination window resides
- * @xid: the windowing system id of the destination window.
- * @protocol: (out): location where the supported DND protocol is returned.
- *
- * Finds out the DND protocol supported by a window.
- *
- * Return value: the windowing system id of the window where the drop
- *    should happen. This may be @xid or the id of a proxy window,
- *    or zero if @xid does not support Drag and Drop.
- *
- * Since: 2.2
- */
-GdkNativeWindow
-gdk_drag_get_protocol_for_display (GdkDisplay      *display,
-                                   GdkNativeWindow  xid,
-                                   GdkDragProtocol *protocol)
-{
-  return GDK_DISPLAY_GET_CLASS (display)->get_drag_protocol (display, xid, protocol, NULL);
-}
-
 /**
  * gdk_display_open:
  * @display_name: the name of the display to open
index 7f7259ab7ad1268fd594cee0b27098c055cdb3b2..1126d961d67b6ea0aea7cc9d44972e4c5e7136d1 100644 (file)
@@ -164,10 +164,6 @@ struct _GdkDisplayClass
 
   GList *                    (*list_devices)       (GdkDisplay *display);
   GdkAppLaunchContext *      (*get_app_launch_context) (GdkDisplay *display);
-  GdkNativeWindow            (*get_drag_protocol)      (GdkDisplay      *display,
-                                                        GdkNativeWindow  winid,
-                                                        GdkDragProtocol *protocol,
-                                                        guint           *version);
 
   void                       (*before_process_all_updates) (GdkDisplay *display);
   void                       (*after_process_all_updates)  (GdkDisplay *display);
index 5840569449dbb8a383aaafa1815dc505211bd34a..85f9305fbaa6be9d631d23a309adf6204d9aa561 100644 (file)
@@ -128,10 +128,6 @@ GdkDragContext * gdk_drag_begin_for_device (GdkWindow      *window,
                                             GdkDevice      *device,
                                             GList          *targets);
 
-GdkNativeWindow gdk_drag_get_protocol_for_display (GdkDisplay       *display,
-                                                   GdkNativeWindow   xid,
-                                                   GdkDragProtocol  *protocol);
-
 void    gdk_drag_find_window_for_screen   (GdkDragContext   *context,
                                            GdkWindow        *drag_window,
                                            GdkScreen        *screen,
index 019b0ea94bdad7f64d53de7e64692143a2f89548..5b1d43f3d5181f4213988354a50cceb69bd1760c 100644 (file)
@@ -10657,6 +10657,28 @@ gdk_window_register_dnd (GdkWindow *window)
   GDK_WINDOW_IMPL_GET_CLASS (window->impl)->register_dnd (window);
 }
 
+/**
+ * gdk_window_get_drag_protocol:
+ * @window: the destination window
+ * @target: (out) (allow-none) (transfer full): location of the window
+ *    where the drop should happen. This may be @window or a proxy window,
+ *    or %NULL if @window does not support Drag and Drop.
+ *
+ * Finds out the DND protocol supported by a window.
+ *
+ * Returns: the supported DND protocol.
+ *
+ * Since: 3.0
+ */
+GdkDragProtocol
+gdk_window_get_drag_protocol (GdkWindow  *window,
+                              GdkWindow **target)
+{
+  g_return_val_if_fail (GDK_IS_WINDOW (window), GDK_DRAG_PROTO_NONE);
+
+  return GDK_WINDOW_IMPL_GET_CLASS (window->impl)->get_drag_protocol (window, target);
+}
+
 /**
  * gdk_drag_begin:
  * @window: the source window for this drag.
index 1cac906945c6b3ee291bc78ac3e23075afd43935..b400ee4937c85ada4594b41814c1d80019f16607 100644 (file)
@@ -780,6 +780,10 @@ void          gdk_window_set_opacity     (GdkWindow       *window,
                                           gdouble          opacity);
 void          gdk_window_register_dnd    (GdkWindow       *window);
 
+GdkDragProtocol
+              gdk_window_get_drag_protocol(GdkWindow      *window,
+                                          GdkWindow      **target);
+
 void gdk_window_begin_resize_drag (GdkWindow     *window,
                                    GdkWindowEdge  edge,
                                    gint           button,
index fd9add2de0ef085a3209e798c04feed58dd0de4a..e0888134562de2395ccae1b6bfe0ae6d1c7b79a2 100644 (file)
@@ -248,6 +248,8 @@ struct _GdkWindowImplClass
   void         (* set_composited)       (GdkWindow *window,
                                          gboolean   composited);
   void         (* destroy_notify)       (GdkWindow *window);
+  GdkDragProtocol (* get_drag_protocol) (GdkWindow *window,
+                                         GdkWindow **target);
   void         (* register_dnd)         (GdkWindow *window);
   GdkDragContext * (*drag_begin)        (GdkWindow *window,
                                          GdkDevice *device,
index 2e30695e3a2999d2ef5b4ef789a519657fbccae6..2cf17ca8a6c150b82aaed17f8e9247dd8599ebc1 100644 (file)
@@ -2556,13 +2556,6 @@ gdk_x11_display_error_trap_pop_ignored (GdkDisplay *display)
   gdk_x11_display_error_trap_pop_internal (display, FALSE);
 }
 
-extern GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
-extern GdkNativeWindow      _gdk_x11_display_get_drag_protocol      (GdkDisplay *display,
-                                                                     GdkNativeWindow  xid,
-                                                                     GdkDragProtocol *protocol,
-                                                                     guint           *version);
-
-
 /**
  * gdk_x11_set_sm_client_id:
  * @sm_client_id: the client id assigned by the session manager when the
@@ -2665,7 +2658,6 @@ gdk_x11_display_class_init (GdkX11DisplayClass * class)
   display_class->supports_composite = gdk_x11_display_supports_composite;
   display_class->list_devices = gdk_x11_display_list_devices;
   display_class->get_app_launch_context = _gdk_x11_display_get_app_launch_context;
-  display_class->get_drag_protocol = _gdk_x11_display_get_drag_protocol;
   display_class->get_cursor_for_type = _gdk_x11_display_get_cursor_for_type;
   display_class->get_cursor_for_name = _gdk_x11_display_get_cursor_for_name;
   display_class->get_cursor_for_pixbuf = _gdk_x11_display_get_cursor_for_pixbuf;
index 36e340f07bddb6be1e3b0513198eb496abdd4ca7..bac0b1321b2d5aa568e37ac10a0d3e3443c8309a 100644 (file)
@@ -182,6 +182,12 @@ void _gdk_x11_display_update_grab_info_ungrab (GdkDisplay *display,
 void _gdk_x11_display_queue_events            (GdkDisplay *display);
 
 
+GdkAppLaunchContext *_gdk_x11_display_get_app_launch_context (GdkDisplay *display);
+GdkNativeWindow      _gdk_x11_display_get_drag_protocol      (GdkDisplay *display,
+                                                              GdkNativeWindow  xid,
+                                                              GdkDragProtocol *protocol,
+                                                              guint           *version);
+
 gboolean    _gdk_x11_display_set_selection_owner   (GdkDisplay *display,
                                                     GdkWindow  *owner,
                                                     GdkAtom     selection,
index 4f2d2e92e61b54d360ceb03603eeb1c124efaaeb..dd420885bac76db234871852e2548462c6d4a911 100644 (file)
@@ -1108,6 +1108,32 @@ gdk_x11_window_destroy_notify (GdkWindow *window)
   g_object_unref (window);
 }
 
+static GdkDragProtocol
+gdk_x11_window_get_drag_protocol (GdkWindow *window,
+                                  GdkWindow **target)
+{
+  GdkDragProtocol protocol;
+  GdkDisplay *display;
+  guint version;
+  Window xid;
+
+  display = gdk_window_get_display (window);
+  xid = _gdk_x11_display_get_drag_protocol (display,
+                                            GDK_WINDOW_XID (window->impl_window),
+                                            &protocol,
+                                            &version);
+
+  if (target)
+    {
+      if (xid != None)
+        *target = gdk_x11_window_foreign_new_for_display (display, xid);
+      else
+        *target = NULL;
+    }
+
+  return protocol;
+}
+
 static void
 update_wm_hints (GdkWindow *window,
                 gboolean   force)
@@ -4779,6 +4805,7 @@ gdk_window_impl_x11_class_init (GdkWindowImplX11Class *klass)
   impl_class->set_opacity = gdk_x11_window_set_opacity;
   impl_class->set_composited = gdk_x11_window_set_composited;
   impl_class->destroy_notify = gdk_x11_window_destroy_notify;
+  impl_class->get_drag_protocol = gdk_x11_window_get_drag_protocol;
   impl_class->register_dnd = _gdk_x11_window_register_dnd;
   impl_class->drag_begin = _gdk_x11_window_drag_begin;
   impl_class->process_updates_recurse = gdk_x11_window_process_updates_recurse;
index 174ea93e05d50018f132a8679e1b6b6fb9f844ab..d88f756690a03c167bfa5b3b391ecb12952fecf7 100644 (file)
@@ -1112,7 +1112,8 @@ gtk_socket_add_window (GtkSocket       *socket,
 
       private->need_map = private->is_mapped;
 
-      if (gdk_drag_get_protocol_for_display (display, xid, &protocol))
+      protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
+      if (protocol)
        gtk_drag_dest_set_proxy (GTK_WIDGET (socket), private->plug_window,
                                 protocol, TRUE);
 
@@ -1524,9 +1525,8 @@ gtk_socket_filter_func (GdkXEvent *gdk_xevent,
              (xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "_MOTIF_DRAG_RECEIVER_INFO")))
            {
              gdk_error_trap_push ();
-             if (gdk_drag_get_protocol_for_display (display,
-                                                    xevent->xproperty.window,
-                                                    &protocol))
+              protocol = gdk_window_get_drag_protocol (private->plug_window, NULL);
+              if (protocol)
                gtk_drag_dest_set_proxy (GTK_WIDGET (socket),
                                         private->plug_window,
                                         protocol, TRUE);